package xdu.lz.stage1_basic.chapter2_api.c_daemonThread;

public class Code03_DaemonThread {
    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            Thread healthCheck = new Thread(new Runnable() {
                @Override
                public void run() {
                    while (true){
                        System.out.println("心跳检测...");
                        try {
                            Thread.sleep(2_000L);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }

            );
            healthCheck.setDaemon(true);
            healthCheck.start();
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("t1执行完毕..");
        });

        t1.start();
    }
}
